package com.haifeng.asms.api.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.haifeng.asms.business.UserService;
import com.haifeng.asms.commons.common.Rest;
import com.haifeng.asms.dao.model.dto.UserDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户 前端控制器
 * </p>
 *
 * @author Haifeng
 * @since 2020-06-21
 */
@Api(tags = "用户管理")
@ApiSort(2)
@RestController
@AllArgsConstructor
@RequestMapping("/api/user")
public class UserController {

    private final UserService userService;

    /**
     * 根据用户名获取用户信息
     * @param username 用户名
     * @return
     */
    @ApiOperationSupport(order=1)
    @ApiOperation(value = "根据用户名获取用户信息",notes="根据用户名获取用户信息",produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
    @GetMapping("/getUserByUsername")
    public Rest<UserDto> getUserByUsername(@RequestParam("username") String username){
        return Rest.success(userService.getUserByUsername(username));
    }
}

